import { login } from '@/api/login/index'
const state = {
    token: '',
    userInfo: {}
}
const actions = {
    async getLogin({ commit }, data) {
        // 发起请求
        commit('setToken', token)
    },
    logOut({ commit }) {
        commit('removeToken')
        commit('setUserInfo', {})
    },
}

const mutations = {
    setToken(state, token) {
        state.token = token
    },
    removeToken(state) {
        state.token = null
    },
    // 获取用户信息
    setUserInfo(state, userInfo) {
        state.userInfo = userInfo
    },
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}